18. Exercise: Preference Change Listener

Exercise Code

In this exercise, you will get to reflect any changes that happen in the Preferences onto the app.

Exercise: T06.05-Exercise-PreferenceChangeListener

Preference Change Listener

Now it's your turn to extend the SharedPreference Change Listener and override its methods to update preference changes.

SOLUTION:
  • Implement OnSharedPreferenceChangeListener
  • Override the onSharedPreferenceChanged method and update the show bass preference
  • Register the listener
  • Override onDestroy and unregister the listener